#!/bin/bash
# Report OS startup time to collector
BOOT_TIME=`date -d @$(sed -n '/^btime /s///p' /proc/stat) +"%Y-%m-%d %H:%M:%S"`
PROC1_TIME=`ls -ld /proc/1 --time-style "+%Y-%m-%d %H:%M:%S" | awk '{print $(NF-2), $(NF-1)}'`
LOGIN_TIME=`date +"%Y-%m-%d %H:%M:%S"`
echo "lztool: root user logged on" > /dev/kmsg

HOST=`hostname`
IP=` ifconfig eth0 | grep "inet addr:" | awk '{gsub("addr:", "", $2); print $2}'`
ISCSI_INT=`dmesg | grep "iSCSI Initiator" | awk '{gsub("]","", $2); print $2}'`
BOOT_INT=`dmesg | tail -n 1 |  awk '{gsub("]","", $2); print $2}'`

msg="\"$HOST\",\"$IP\",\"$BOOT_TIME\",\"$ISCSI_INT\",\"$PROC1_TIME\",\"$BOOT_INT\",\"$LOGIN_TIME\""
echo "lztool: $msg" > /var/log/syslog
echo $msg

~/scr.exp root:iforgotla@10.20.30.41 /pbfd/TBIRD/DATA "echo $msg >> client_boot_time.csv"

